# -*- coding: utf-8 -*-
# @Time : 2021/9/17 15:41
# @Author : Mr  jelis
# @Email : 1402615849@qq.com
# @File : text_cuxiaohuodong.py
# @Project : mryx_test

"""促销活动用例"""
import unittest
from page.home_page import HomePage
from page.mid_autumn_page import MidAutumn
from page.detail_page import DetailPage
from time import sleep
from testcase.base_case import BaseCase
from page.shopping_page import Shopping
from page.today_miaosha_page import TodayMiaoSha
from utils.toast import Toast
class CuXiao(BaseCase):
    def test_marsx_st_cuxiao_001(self):
        """促销活动的商品详情页加入购物车"""
        hp=HomePage(self.driver)
        ma=MidAutumn(self.driver)
        dp=DetailPage(self.driver)
        sp = Shopping(self.driver)
        sleep(15)
        #点击中秋活动
        hp.zhongqiu()
        sleep(3)
        #点击商品进入详情页
        ma.shangping()
        sleep(4)
        #加入购物车
        dp.addshopping()
        sleep(5)
        """断言"""
        a=dp.get_name()
        sleep(5)
        dp.to_shopping()
        sleep(5)
        b=sp.shangping_name()
        self.assertIn(a,b)
        sleep(5)
    def test_marsx_st_cuxiao_002(self):
        """促销活动商品主页加入购物车"""
        hp = HomePage(self.driver)
        ma = MidAutumn(self.driver)
        sleep(15)
        # 点击中秋活动
        hp.zhongqiu()
        sleep(3)
        #加入购物车
        ma.add_shopping()
        sleep(10)
        #断言
        ts=Toast(self.driver)
        ts.toast("加车成功!")
    def test_marsx_st_cuxiao_003(self):
        """删除购物车商品"""
        hp = HomePage(self.driver)
        ma = MidAutumn(self.driver)
        sp = Shopping(self.driver)
        dp = DetailPage(self.driver)
        sleep(15)
        # 点击中秋活动
        hp.zhongqiu()
        sleep(5)
        # 点击商品进入详情页
        ma.shangping()
        sleep(4)
        # 加入购物车
        dp.addshopping()
        sleep(5)
        #进入购物车
        dp.to_shopping()
        sleep(5)
        # 删除购物车商品
        sp.delete()
        sleep(3)
        # 确定删除
        sp.sure()
        sleep(5)
        #断言
        height=sp.size().get("height")
        print(height)
        self.assertEqual(381,height)
        sleep(5)

    def test_test_marsx_st_cuxiao_004(self):
        """参加秒杀活动加入购物车"""
        hp=HomePage(self.driver)
        ms=TodayMiaoSha(self.driver)
        sp = Shopping(self.driver)
        sleep(15)
        # 进入秒杀页面
        hp.miaosha()
        sleep(6)
        # 进行秒杀
        ms.qianggou()
        sleep(10)
        #断言
        name1=ms.shangpingname()
        ms.enter_shopping()
        sleep(3)
        name2 = sp.shangping_name()
        self.assertIn(name1,name2)
        sleep(10)
    def test_test_marsx_st_cuxiao_005(self):
        """参加秒杀活动加入购物车并编辑购物车数量"""
        hp = HomePage(self.driver)
        ms = TodayMiaoSha(self.driver)
        sp = Shopping(self.driver)
        sleep(5)
        # 进入秒杀页面
        hp.miaosha()
        sleep(3)
        # 进行秒杀
        ms.qianggou2()
        sleep(10)
        # 进入购物车
        ms.enter_shopping()
        sleep(5)
        # 修改商品数量
        sp.add_number()
        sleep(5)
        #断言
        self.assertIn("3",sp.shangping_num())


if __name__ == '__main__':
    unittest.main()

